home *** CD-ROM | disk | FTP | other *** search
- Path: news.sprintlink.net!datalytics!usenet
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.lang.c++,gnu.g++.help
- Subject: Re: Unable to compile inline functions
- Date: Fri, 05 Apr 1996 12:11:03 -0500
- Organization: Datalytics, Inc
- Message-ID: <31655427.20FB@datalytics.com>
- References: <4js108$pm4@ncar.ucar.edu> <4jt6bf$4cn@clarknet.clark.net>
- NNTP-Posting-Host: 204.62.224.71
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Harlan Messinger wrote:
- >
- > James Adams (jadams@sage.cgd.ucar.edu) wrote:
- > : Hello,
- > :
- > : I am attempting to compile a C++ program which has member functions
- > : defined as inline, and I get unresolved errors from my linker. For instance
- > : I have a class defined as such:
- > :
- >
- > When you compile a module that invokes a function that is declared inline
- > in a header file, the compiler has to be able to find the inline
- > definition in order to handle the code. It's the compiler that converts an
- > inline function call into the function's body. But the compiler only knows
- > what's in the file it's compiling, so if you put the function's definition
- > in a separate file that isn't #included, it's invisible to the compiler.
-
- The inline keyword is a suggestion to the compiler. It is not
- obligated to follow your suggestion. In this case, the compiler
- silently ignored the inline keyword since it couldn't find the
- definition of the function; it expected the function to be out
- of line instead. However, in the translation unit that
- contained the function definition, you still indicated that it
- was inline. As a result, the compiler didn't generate object
- code for that function to be found by the linker for the
- references to it in the other translation units.
-
- --
- Robert Stewart | My opinions are usually my own.
- Datalytics, Inc. | stew@datalytics.com
-